package com.wlys.player.ui.asynctask;

import java.util.List;

import android.content.Context;
import android.os.AsyncTask;
import com.wlys.player.controler.manager.TrackManager;
import com.wlys.player.model.Track;
import com.wlys.player.ui.adapter.TrackAdapter;

public class TrackTask extends AsyncTask<Void, Void, List<Track>>
{

    Context mContext;
    TrackAdapter mTrackAdapter;
    TrackManager mTrackManager;

    public TrackTask(Context context,TrackAdapter trackAdapter)
    {
        mContext = context;
        mTrackAdapter = trackAdapter;
        mTrackManager = new TrackManager();
    }

    @Override
    protected List<Track> doInBackground(Void... params)
    {
        return mTrackManager.getAll(mContext);
    }

    @Override
    protected void onPostExecute(List<Track> result)
    {
        mTrackAdapter.addAll(result);
        mTrackAdapter.notifyDataSetChanged();
    }

}
